package com.nefu.editor.core.mapper.provider;

import com.nefu.editor.core.model.Order;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author chenchenT
 * @date : 18-11-14
 * @since : java 8
 */
public class OrderProvider {

    public String selectOrderByCondition(Order order) {
        return new SQL() {
            {
                SELECT("order_systemId as systemId,order_userSystemId as userSystemId, order_writerSystemId as writerSystemId, order_articleSystemId  as articleSystemId," +
                        "order_sum as sum,order_status as status, order_time as time, order_limitDay as limitDay, order_deadLine as deadLine," +
                        "order_totalPay as totalPay, order_paid as paid, order_progress as progress");
                FROM("t_order");
                if (null != order.getSystemId()) {
                    WHERE("order_systemId=#{systemId}");
                }
                if (null != order.getUserSystemId()) {
                    WHERE("order_userSystemId=#{userSystemId}");
                }
                if (null != order.getWriterSystemId()) {
                    WHERE("order_writerSystemId=#{writerSystemId}");
                }
                if (null != order.getArticleSystemId()) {
                    WHERE("order_articleSystemId=#{articleSystemId}");
                }
                if (null != order.getStatus()) {
                    WHERE("order_status=#{status}");
                }
            }
        }.toString();
    }

}
